﻿ using Maticsoft.BLL;
    using Maticsoft.Model;
    using System;
    using System.Text;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using Wuqi.Webdiyer;

    public partial class WebPage_DiaoCha_SumPage : SystemBBasePage
    {

        private Maticsoft.BLL.vote_question vq = new Maticsoft.BLL.vote_question();

        private void getSumPage()
        {
            Maticsoft.BLL.vote_question _question = new Maticsoft.BLL.vote_question();
            StringBuilder builder = new StringBuilder();
            builder.Append("<tr >");
            builder.Append("<td width='40'>ID</td>");
            builder.Append("<td width='400'>标题</td>");
            builder.Append("<td width='100'>状态</td>");
            builder.Append("<td width='100'>排序</td>");
            builder.Append("<td width='500'>操作</td>");
            builder.Append("</tr>");
            StringBuilder builder2 = new StringBuilder();
            int num = 0;
            foreach (Maticsoft.Model.vote_question _question2 in _question.GetModelList(""))
            {
                if ((num % 2) != 0)
                {
                    builder.Append("<tr>");
                }
                else
                {
                    builder.Append("<tr class='alt'>");
                }
                builder2.Append("<td>" + _question2.id + "</td>");
                builder2.Append("<td>" + _question2.Title + "</td>");
                if (_question2.is_show == 1)
                {
                    builder2.Append("<td>显示</td>");
                }
                else if (_question2.is_show == 0)
                {
                    builder2.Append("<td> 隐藏</td>");
                }
                builder2.Append("<td>" + _question2.order + "</td>");
                builder2.Append("<td class='op'>");
                if (_question2.is_show == 1)
                {
                    builder2.Append("<a href='DiaoCha_SumPage.aspx?change_show=0&show=" + _question2.id + "'>隐藏</a>\t");
                }
                else if (_question2.is_show == 0)
                {
                    builder2.Append("<a href='DiaoCha_SumPage.aspx?change_show=1&show=" + _question2.id + "'>显示</a>\t");
                }
                else
                {
                    builder2.Append("<a href='DiaoCha_SumPage.aspx?change_show=0&show=" + _question2.id + ">隐藏</a>\t");
                }
                builder2.Append("<a href='DiaoCha_Wenti_Xuanxiang.aspx?id=1 '>选项</a>");
                builder2.Append("<a href='DiaoCha_Wenti_Bianji.aspx?edit=" + _question2.id + "'>编辑</a>");
                builder2.Append("<a class=\"remove-record\" href='DiaoCha_SumPage.aspx?del=" + _question2.id + "'>删除</a>");
                builder2.Append("</td>");
                builder2.Append("</tr>");
                num++;
            }
            this.Literal1.Text = builder.ToString();
            this.Literal2.Text = builder2.ToString();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.CHeaderControl1.Select = "diaocha";
            this.DiaoCha1.Select = "Wenti";
            this.getSumPage();
            if (base.Request.QueryString["change_show"] != null)
            {
                this.setShow(int.Parse(base.Request.QueryString["change_show"].ToString()), int.Parse(base.Request.QueryString["show"].ToString()));
            }
        }

        private void setShow(int id, int id1)
        {
            Maticsoft.BLL.vote_question _question = new Maticsoft.BLL.vote_question();
            Maticsoft.Model.vote_question model = new Maticsoft.Model.vote_question();
            foreach (Maticsoft.Model.vote_question _question3 in _question.GetModelList("id=" + id1))
            {
                model.id = _question3.id;
                model.Title = _question3.Title;
                model.Type = _question3.Type;
                model.order = _question3.order;
                model.is_show = id;
            }
            _question.Update(model);
            base.SetSuccess("更新成功！");
        }
    }


